package usaco.c2009.march.silver;

import java.util.Scanner;

/*
 * p3209
 * USACO 2009 March - Silver
 * Hint: use a stack. Note that the same algorithm runs much faster in C/C++. Still cannot get AC using Java.
 */

public class p3209 {

	static int N, S;
	static int[] H, lu, st;

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		N = scanner.nextInt();
		H = new int[N];
		lu = new int[N];
		st = new int[N];
		S = 0;
		
		for (int i=0;i<N;++i) {
			H[i] = scanner.nextInt();
			if (i > 0) {
				while (S>0 && H[st[S-1]] < H[i]) {
					lu[st[S-1]] = i+1;
					S--;
				}
				
			}
			st[S] = i;
			S++;
		}
		
		for (int i=0;i<N;++i) {
			System.out.println(lu[i]);
		}
		
	}

}